//TODO: Please write code in this file.
function printInventory(inputs) {
    var countInputs = [];
    for(var i = 0; i < inputs.length; i++) {
        if (!countInputs.length) {
            var input = {};
            input.barcode = inputs[0];
            input.count = 1;
            countInputs.push(input);
            continue;
        }
        for (var j = 0, max = countInputs.length; j < max; j++) {
            if (countInputs[j].barcode == inputs[i]) {
                countInputs[j].count++;
            }
            else if (countInputs[j].barcode != inputs[i] && j === max - 1) {
                var inputNew = {};
                inputNew.barcode = inputs[i];
                inputNew.count = 1;
                countInputs.push(inputNew);
            }
        }
    }
    for(var i = 0; i < countInputs.length; i++){
        for(var j = 0; j < allItems.length; j++){
            if(countInputs[i].barcode == allItems[j].barcode){
                countInputs[i].name = allItems[j].name;
                countInputs[i].unit = allItems[j].unit;
                countInputs[i].price = allItems[j].price;
            }
        }

    }
    var sum_money=0;
    for(i=0;i<countInputs.length;i++){
        result += '名称：'+countInputs[i].name+'，数量：'+countInputs[i].count+countInputs[i].unit+'，单价：'+countInputs[i].price.toFixed(2)+'(元)，小计：'+(countInputs[i].price*countInputs[i].count).toFixed(2)+'(元)\n';
        sum_money += (countInputs[i].count*countInputs[i].price);
    }
    result='***<没钱赚商店>购物清单***\n'+result+'----------------------\n'+'总计：'+sum_money.toFixed(2)+'(元)\n'+'**********************';
    console.log(result);

}